﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Manager_Quangcao_Controls_UC_Quangcao : System.Web.UI.UserControl
{
    BUS_Advertise Ad = new BUS_Advertise();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           LoadData();
        }
        
    }
    public void LoadData()
    {
        DataTable dt = new DataTable();
        
        dt = Ad.Advertise_GetByTop(0, "Position = '"+drlChonquangcao.SelectedValue+"'", "[Order]");
                
               
        gvQuangcao.DataSource = dt;
        gvQuangcao.DataBind();

    }
    protected void drlChonquangcao_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (drlChonquangcao.SelectedValue!="0")
        {
            gvQuangcao.DataSource = Ad.Advertise_GetByTop(0, "Position = '" + drlChonquangcao.SelectedValue + "'", "[Order]");
            gvQuangcao.DataBind();
        }
        
        
    }
    protected void gvQuangcao_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Chitiet")
        {
            Response.Redirect("Chitietquangcao.aspx?Id=" + e.CommandArgument);
        }
        else if(e.CommandName=="Xoa")
        {
            Ad.Advertise_Delete(e.CommandArgument.ToString());
            Response.Redirect(Request.RawUrl);
        }
    }
}